<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>员工列表</title>
    <style>
        h1{
            text-align: center;
        }
        table{
            width: 700px;
            border-collapse: collapse;
            text-align: center;
            margin: 0 auto;
            border: 1px solid plum;
        }
        td,th{
            border: 1px solid red;
            line-height: 35px;
        }
        tr:nth-child(odd){
            background-color: aquamarine;
        }
        tr:hover{
            background-color: bisque;
            cursor: pointer;
        }
        .p1{
            width: 700px;
            text-align: right;
            margin: 0 auto;
        }
    </style>
</head>
<body>
    <h1>员工列表</h1>
    <!--导入jQuery-->
    <script th:src="@{/webjars/jquery/3.5.1/jquery.min.js}"></script>
    <script>
        $(function () {
            //绑定删除链接
            $(".delete").click(function () {
                //alert(this.href);
                if (confirm("您确定删除该记录？"))
                //删除，提交表单f1
                $("#f1").attr("action",this.href).submit();
                //屏蔽超链接的默认跳转
                return false;
            });
        });
    </script>
    <p class="p1">
        <a th:href="@{/emp/ui}">新增</a>
    </p>
    <table>
        <tr>
            <th>员工编号</th>
            <th>姓名</th>
            <th>性别</th>
            <th>年龄</th>
            <th>生日</th>
            <th>证件类型</th>
            <th>操作</th>
        </tr>
        <tr th:each="emp:${empList}">
            <td th:text="${emp.id}"></td>
            <td th:text="${emp.name}"></td>
            <td th:text="${emp.sex}"></td>
            <td th:text="${emp.age}"></td>
            <td th:text="${#calendars.format(emp.birthday,'yyyy-MM-dd')}"></td>
            <td th:text="${emp.idType}"></td>
            <td>
                <a th:href="@{'/emp/'+${emp.id}}">修改</a>
                |
                <a class="delete" th:href="@{'/emp/'+${emp.id}}">删除</a>
            </td>
        </tr>
    </table>
    <p class="p1">
        【总页数：<span th:text="${pageCount}"></span>】
        【当前第<span th:text="${pageNo}"></span>页】
        <a th:href="@{/emp/1/5}">首页</a>
        <a th:if="${pageNo > 1}" th:href="@{'/emp/' + ${pageNo -1} + '/' + ${pageSize} }">上一页</a>
        <a th:if="${pageNo < pageCount}" th:href="@{'/emp/' + ${pageNo +1} + '/' + ${pageSize} }">下一页</a>
        <a th:href="@{'/emp/' + ${pageCount} + '/' + ${pageSize} }">尾页</a>
    </p>
</body>
<form id="f1" method="post">
    <input type="hidden" name="_method" value="DELETE">
</form>
</html>